release-19.1: storage: avoid copying marshalled RaftCommand when encoding #36670
+51
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #36392.
/cc @cockroachdb/release
Informs #36347.
This change avoids the unnecessary allocation and memory copy present in
Raft command encoding. This extra work is expensive for large commands
like
AddSSTable
requests. Even for smaller requests, this work wasstill a serious problem because it took place under heavily contended
locks. For instance, the encoding in
defaultSubmitProposalLocked
tookplace under the Replica mutex, which serializes all Raft proposals for
a Range. The other two locations fixed took place under the Raft mutex.
While less heavily contended, this was still slowing down the Raft
processing goroutine.
This is a less dramatic version of a change I've been working on. The
full change lifts the slice allocation and most of the RaftCommand proto
marshalling all the way out of
defaultSubmitProposalLocked
and out ofthe
Replica.mu
critical section. This commit gets us part of the waythere sets the stage for the rest of the change.
Release note: None